package com.laiketui.common.mapper;

import com.laiketui.domain.plugin.group.GoGroupOrderDetailsModel;
import com.laiketui.core.exception.LaiKeAPIException;
import com.laiketui.core.db.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * 拼团订单明细
 *
 * @author Trick
 */
public interface GoGroupOrderDetailsModelMapper extends BaseMapper<GoGroupOrderDetailsModel> {
    @Override
    List<Map<String, Object>> selectDynamic(Map<String, Object> map) throws LaiKeAPIException;

    @Override
    int countDynamic(Map<String, Object> map) throws LaiKeAPIException;


    /**
     * 当前用户是否参与此团
     *
     * @param storeId -
     * @param ptCode  -
     * @param userId  -
     * @return Integer
     * @throws LaiKeAPIException-
     * @author Trick
     * @date 2021/3/24 15:30
     */
    @Select("select count(1) from lkt_go_group_order where store_id = #{storeId} and ptcode=#{ptCode} and user_id=#{userId} and status not in(0,6,7) ")
    Integer getGroupUserSelf(int storeId, String ptCode, String userId) throws LaiKeAPIException;

    /**
     * 修改订单状态
     *
     * @param storeId -
     * @param orderno -
     * @param status  -
     * @return Integer
     * @throws LaiKeAPIException -
     * @author Trick
     * @date 2021/4/1 11:19
     */
    @Update("update lkt_go_group_order_details set r_status=#{status} where r_sNo=#{orderno} and store_id=#{storeId}")
    Integer updateStatus(int storeId, String orderno, int status) throws LaiKeAPIException;
}